package com.lhkj.ct.meta.admin.model.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.lhkj.ct.base.enums.GlobalStatus;
import com.lhkj.ct.base.model.IBaseTree;
import com.lhkj.ct.base.model.Tree;
import com.lhkj.ct.base.validator.group.ValGroups;
import com.lhkj.ct.meta.admin.common.enums.MenuType;
import com.lhkj.ct.meta.admin.validation.MenuGroupSequenceProvider;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.URL;
import org.hibernate.validator.group.GroupSequenceProvider;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 *  菜单
 */
@Setter
@Getter
@TableName("tbl_menu")
@GroupSequenceProvider(MenuGroupSequenceProvider.class)
public class TblMenu implements IBaseTree<String>, Tree<TblMenu> {

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @ApiModelProperty("主键")
    private String id;

    /**
     * 父级id
     */
    @ApiModelProperty(value = "上级菜单id", notes = "顶级为0", example = "0")
    @NotBlank(message = "请选择上级菜单", groups = {ValGroups.Insert.class, ValGroups.Update.class})
    private String parentId;

    /**
     * 菜单名称
     */
    @ApiModelProperty("菜单名称")
    @NotBlank(message = "请输入菜单名称", groups = {ValGroups.Insert.class, ValGroups.Update.class})
    @Length(max = 25, message = "菜单名称不能超过{max}字符", groups = {ValGroups.Insert.class, ValGroups.Update.class})
    private String name;

    @ApiModelProperty("图标")
    private String icon;

    /**
     * 菜单类型 1.目录 2.菜单 3.按钮 4.外链
     */
    @ApiModelProperty("菜单类型 1.目录 2.菜单 3.按钮 4.外链")
    @NotNull(message = "请选择菜单类型", groups = {ValGroups.Insert.class, ValGroups.Update.class})
    private MenuType type;

    /**
     * 路由路径
     */
    @ApiModelProperty("路由路径")
    @NotBlank(message = "请输入路由路径", groups = {catalog.class, menu.class, link.class})
    @Length(max = 255, message = "路由路径不能超过{max}字符", groups = {catalog.class, menu.class, link.class})
    @URL(message = "外链链接不合法", groups = {link.class})
    private String path;

    /**
     * 路由组件path
     */
    @ApiModelProperty("全路径")
    @NotBlank(message = "请输入全路径", groups = {menu.class})
    private String fullPath;

    /**
     * 页面路径
     */
    @ApiModelProperty("页面路径（组件路径）")
    @NotBlank(message = "请输入组件路径", groups = {menu.class})
    @Length(max = 255, message = "组件路径不能超过{max}字符", groups = {menu.class})
    private String component;

    /**
     * 路由组件name
     */
    @ApiModelProperty("路由组件name")
    @NotBlank(message = "请输入组件name", groups = {menu.class})
    private String componentName;

//    /**
//     * 跳转路径（弃用）
//     */
//    @ApiModelProperty("跳转路由")
//    @Deprecated
//    private String redirect;

    /**
     * 权限标识
     */
    @ApiModelProperty("权限标识")
    @NotBlank(message = "权限标识不能为空", groups = {button.class})
    private String perm;

    @ApiModelProperty(value = "路由meta属性")
    private String meta;

    /**
     * 菜单状态（0正常 1停用）
     */
    @ApiModelProperty(value = "菜单状态", notes = "0正常 1停用", example = "0")
    @NotNull(message = "请选择菜单状态", groups = {ValGroups.Insert.class, ValGroups.Update.class})
    private GlobalStatus status;

    /**
     * 排序
     */
    @ApiModelProperty("排序")
    @NotNull(message = "请输入排序", groups = {ValGroups.Insert.class, ValGroups.Update.class})
    private Integer sort;

    /**
     * 父节点路径，以英文逗号(,)分割
     */
    @ApiModelProperty(value = "父节点路径", hidden = true)
    private String treePath;

    /**
     * 是否缓存
     */
    @ApiModelProperty(value = "是否缓存", notes = "true为开启, false为关闭", example = "true")
    private Boolean noCache;

    /**
     * 显示状态（0显示 1隐藏）
     */
    @ApiModelProperty(value = "是否隐藏", notes = "false为显示 true为隐藏", example = "false")
    private Boolean hidden;

    /**
     * 显示状态（0显示 1隐藏）
     */
    @ApiModelProperty(value = "默认展开", notes = "false为收起 true为展开", example = "false")
    private Boolean expand;

    /**
     *  子菜单
     */
    @ApiModelProperty(value = "子菜单", hidden = true)
    @TableField(exist = false)
    private List<TblMenu> children;

    public interface catalog{

    }

    public interface menu{

    }

    public interface button{

    }

    public interface link{

    }

}
